package com.zhouxiaoge.source;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author 周小哥 gqzmy@163.com 2022/7/21
 */
public class FileSourceTest {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        DataStreamSource<String> streamSource = env.readTextFile("input/clicks.txt");

        SingleOutputStreamOperator<String> streamOperator = streamSource
                .map((MapFunction<String, String>) value -> value.split(",")[0]);
        streamOperator.print();

        env.execute();
    }
}
